package com.chinamcom.framework.admin.common.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.chinamcom.framework.admin.common.dao.${className}Repository;
import com.chinamcom.framework.admin.common.model.${className};
import com.chinamcom.framework.admin.common.service.${className}Service;

@Service
public class ${className}ServiceImpl implements ${className}Service {

	@Autowired
	private ${className}Repository ${className?uncap_first}Repository;
	
	@Override
	public void save(${className} entity) {
		${className?uncap_first}Repository.save(entity);
	}

	@Override
	public void delete(Long id) {
		${className?uncap_first}Repository.delete(id);
	}

	@Override
	public Page<${className}> list(Integer page, Integer pageSize) {
		Pageable pageable = new PageRequest(page, pageSize);
		return ${className?uncap_first}Repository.findAll(pageable);
	}

	@Override
	public ${className} get(Long id) {
		return ${className?uncap_first}Repository.findOne(id);
	}

}
